package com.zry.fertilizer.ui.activity

import android.annotation.SuppressLint
import com.bumptech.glide.Glide
import com.zry.fertilizer.R
import com.zry.fertilizer.been.ProductNameBean
import com.zry.fertilizer.databinding.ActivityProductInfoBinding
import com.zry.fertilizer.glide.GlideLoadPhoto
import com.zry.fertilizer.ui.base.BaseActivity
import com.zry.fertilizer.utils.UIUtil
import kotlinx.android.synthetic.main.activity_product_info.*
import kotlinx.android.synthetic.main.common_title.*

class ProductInfoActivity : BaseActivity() {
    private var productNameBean: ProductNameBean? = null
    private var productInfoBinding: ActivityProductInfoBinding? = null
    override fun getLayoutId(): Int {
        return R.layout.activity_product_info
    }

    @SuppressLint("SetTextI18n")
    override fun initData() {

        titleCenterText.text = "产品信息"
        commonLeftLinearLayout.setOnClickListener { finish() }

        productNameBean = intent.getSerializableExtra("productNameBean") as ProductNameBean
        productInfoBinding = viewDataBinding as ActivityProductInfoBinding


        UIUtil.setWidgetHeight(productImgLinear, UIUtil.getScreenWidth(this) * 800 / 1080)
        UIUtil.setWidgetHeight(productImg, UIUtil.getScreenWidth(this) * 500 / 1080)
        UIUtil.setWidgetWidth(productImg, UIUtil.getScreenWidth(this) * 500 / 1080)
        Glide.with(this).load(productNameBean!!.ProductImage).apply(GlideLoadPhoto().GlideLoadImg(R.mipmap.ic_launcher, R.mipmap.ic_launcher)).into(productImg)


        productInfoBinding?.productName = productNameBean

        prouductInfoExpiryDate.text = productNameBean!!.ExpiryDate + "月"


    }
}
